Skip to content

Conversation

@benjamincanac
Copy link
Member

@benjamincanac benjamincanac commented Nov 7, 2025

πŸ”— Linked issue

Resolves #2698

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 7, 2025

npm i https://pkg.pr.new/@nuxt/ui@5407

commit: 049b182

@benjamincanac benjamincanac marked this pull request as ready for review December 2, 2025 15:21
return true
}

if ('items' in item && item.items?.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ('items' in item && item.items?.length) {
if ('items' in item) {

Unreachable code in the isDisabled function prevents dropdown items with empty items arrays from being properly marked as disabled. The condition at line 179 checks item.items?.length (truthy only when length > 0), then line 180 checks item.items.length === 0 which can never be true.

View Details

Analysis

Unreachable code in isDisabled prevents empty dropdown items from being disabled

What fails: The isDisabled() function in EditorToolbar.vue incorrectly marks dropdown items with empty items arrays as enabled instead of disabled. The condition at line 179 uses item.items?.length in a logical AND check, which evaluates to falsy when items is an empty array, causing the entire block to be skipped.

How to reproduce:

// Create a toolbar with a dropdown that has an empty items array
const toolbar = {
  items: [
    {
      // Dropdown item with empty items array
      items: [],
      label: 'Empty Dropdown'
      // No explicit disabled property
    }
  ]
}

// Call isDisabled on the dropdown item
const item = toolbar.items[0]
isDisabled(item)  // Returns: false (incorrectly enabled)
                  // Expected: true (should be disabled)

Result: Empty dropdown returns false from isDisabled(), marking it as enabled even though there are no items to display.

Expected: A dropdown with an empty items array should be marked as disabled. The fix changes line 179 from:

if ('items' in item && item.items?.length) {

to:

if ('items' in item) {

This allows the empty items check at line 180 to execute properly and return true for empty dropdowns.

Root cause: The optional chaining operator ?. returns 0 (falsy in JavaScript) when items is an empty array []. The condition item.items?.length fails for empty arrays, preventing the block that handles empty items detection from executing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Add a Built-in Rich Text Editor Component to Nuxt UI

3 participants